/**
 * 
 */
package edu.sjtu.se.prophet.io.gson;

import java.lang.reflect.Type;

import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;

import edu.sjtu.se.prophet.graph.Node;

/**
 * @author willard
 * 
 */
public class NodeSerializer implements JsonSerializer<Node> {

    @Override
    public JsonElement serialize(Node node, Type type,
            JsonSerializationContext context) {
        JsonObject nodeObject = new JsonObject();
        nodeObject.addProperty("id", node.getId());
        nodeObject.add("metrics", context.serialize(node.getMetrics()));
        return nodeObject;
    }

}
